@pexip/media
Enumerations
Interfaces
- AudioDetectionSignals
- AudioSignalDetectionOptions
- DenoiseParams
- ExtendedMediaTrackSettings
- Media
- MediaAttributes
- MediaChangesSignals
- MediaController
- MediaOptions
- MediaProps
- MediaSettings
- PreviewControllerProps
- PreviewEventHandler
- PreviewStreamController
- PreviewStreamParams
- StreamTrackSignals
- VoiceActivityDetectionOptions
Type Aliases
AudioContentHint
Ƭ AudioContentHint: typeof AUDIO_CONTENT_HINTS
[keyof typeof AUDIO_CONTENT_HINTS
]
CreatePreviewStreamController
Ƭ CreatePreviewStreamController: typeof createPreviewStreamController
ExtendedMediaTrackSettingsKey
Ƭ ExtendedMediaTrackSettingsKey: keyof ExtendedMediaTrackSettings
GetDisplayMedia
Ƭ GetDisplayMedia: ReturnType
<typeof createGetDisplayMedia
>
MediaProcessor
Ƭ MediaProcessor: Process
<Promise
<Media
>>
MediaSignals
Ƭ MediaSignals: MediaSignalsRequired
& MediaSignalsOptional
MediaSignalsOptional
Ƭ MediaSignalsOptional: Pick
<Partial
<MediaChangesSignals
>, "onDevicesChanged"
| "onStatusChanged"
| "onAudioMuteStateChanged"
| "onVideoMuteStateChanged"
> & Partial
<StreamTrackSignals
> & Partial
<StreamTrackSignalFinals
>
MediaSignalsRequired
Ƭ MediaSignalsRequired: Pick
<MediaChangesSignals
, "onMediaChanged"
> & AudioDetectionSignals
Pipeline
Ƭ Pipeline<T
>: [Process
<T
>, ...MediaProcessor[]]
A media pipeline to get and process media
Type parameters
Name | Type |
---|---|
T | MediaDeviceRequest |
PreviewInput
Ƭ PreviewInput: MediaDeviceInfoLike
| undefined
Process
Ƭ Process<T
>: (a
: T
) => Promise
<Media
>
Type parameters
Name |
---|
T |
Type declaration
▸ (a
): Promise
<Media
>
Parameters
Name | Type |
---|---|
a | T |
Returns
Promise
<Media
>
ProcessMedia
Ƭ ProcessMedia: (media
: Media
) => undefined
| Media
Type declaration
▸ (media
): undefined
| Media
Parameters
Name | Type |
---|---|
media | Media |
Returns
undefined
| Media
Segmenters
Ƭ Segmenters: { [Property in SegmentationModel]: Segmenter }
StreamTrackSignalFinals
Ƭ StreamTrackSignalFinals: { [key in keyof StreamTrackSignals as `${key}Final`]: Signal<MediaStreamTrack> }
Track state signals that used for the final track that the media pipeline produced
Unsubscribe
Ƭ Unsubscribe: () => void
Type declaration
▸ (): void
Returns
void
UserMediaValidator
Ƭ UserMediaValidator: (status
: UserMediaStatus
) => boolean
Type declaration
▸ (status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
VideoContentHint
Ƭ VideoContentHint: typeof VIDEO_CONTENT_HINTS
[keyof typeof VIDEO_CONTENT_HINTS
]
VideoRenderParams
Ƭ VideoRenderParams: Omit
<RendererOptions
, "effects"
> & { frameRate
: number
; height
: number
; pan?
: boolean
; tilt?
: boolean
; videoSegmentation
: RenderEffects
; width
: number
; zoom?
: boolean
}
VideoStreamTrackProcessorAPIs
Ƭ VideoStreamTrackProcessorAPIs: "stream"
| "canvas"
Use which processor API to process the stream track
stream
- Use MediaStreamTrackProcessor, when available
canvas
- Use Canvas
Variables
AUDIO_CONTENT_HINTS
• Const
AUDIO_CONTENT_HINTS: Object
Audio content hints are only applicable when the MediaStreamTrack contains an audio track
https://www.w3.org/TR/mst-content-hint/#audio-content-hints
Type declaration
Name | Type | Description |
---|---|---|
Music | "music" | The track should be treated as if it contains music data. Generally this might imply tuning or turning off audio-processing components that are used to process speech data to prevent the audio from being distorted. |
NoHint | "" | No hint has been provided, the implementation should make its best-informed guess on how to handle contained audio data. This may be inferred from how the track was opened or by doing content analysis |
Speech | "speech" | The track should be treated as if it contains speech data. Consuming this signal it may be appropriate to apply noise suppression or boost intelligibility of the incoming signal. |
SpeechRecognition | "speech-recognition" | The track should be treated as if it contains data for the purpose of speech recognition by a machine. Consuming this signal it may be appropriate to boost intelligibility of the incoming signal for transcription and turn off audio-processing components that are used for human consumption. |
REQUIRED_SIGNAL_KEYS
• Const
REQUIRED_SIGNAL_KEYS: readonly ["onMediaChanged"
, "onVAD"
, "onSilentDetected"
]
VIDEO_CONTENT_HINTS
• Const
VIDEO_CONTENT_HINTS: Object
Video content hints are only applicable when the MediaStreamTrack contains a video track.
https://www.w3.org/TR/mst-content-hint/#video-content-hints
Type declaration
Name | Type | Description |
---|---|---|
Detail | "detail" | The track should be treated as if video details are extra important. This is generally applicable to presentations or web pages with text content, painting or line art. This setting would normally optimize for detail in the resulting individual frames rather than smooth playback. Artefacts from quantization or downscaling that make small text or line art unintelligible should be avoided. |
Motion | "motion" | The track should be treated as if it contains video where motion is important. This is normally webcam video, movies or video games. Quantization artefacts and downscaling are acceptable in order to preserve motion as well as possible while still retaining target bitrates. During low bitrates when compromises have to be made, more effort is spent on preserving frame rate than edge quality and details. |
NoHint | "" | No hint has been provided, the implementation should make its best-informed guess on how contained video content should be treated. This can for example be inferred from how the track was opened or by doing content analysis. |
Text | "text" | The track should be treated as if video details are extra important, and that significant sharp edges and areas of consistent color can occur frequently. This is generally applicable to presentations or web pages with text content. This setting would normally optimize for detail in the resulting individual frames rather than smooth playback, and may take advantage of encoder tools that optimize for text rendering. Artefacts from quantization or downscaling that make small text or line art unintelligible should be avoided. |
Functions
applyContentHint
▸ applyContentHint<T
>(hint?
): (track
: MediaStreamTrack
) => void
Apply the content hint to the track
Type parameters
Name | Type |
---|---|
T | extends "" | "speech" | "speech-recognition" | "music" | "motion" | "detail" | "text" |
Parameters
Name | Type | Description |
---|---|---|
hint? | T | Content hint |
Returns
fn
▸ (track
): void
Parameters
Name | Type |
---|---|
track | MediaStreamTrack |
Returns
void
areBothGranted
▸ areBothGranted(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
createAudioMixingProcess
▸ createAudioMixingProcess(getCurrrentMedia
, scope?
): Process
<Promise
<Media
>>
Create a Audio Mixing Processor and will own the stream passed-in
Parameters
Name | Type | Default value |
---|---|---|
getCurrrentMedia | () => undefined | MediaStream | undefined |
scope | string | 'mixer' |
Returns
createAudioStreamProcess
▸ createAudioStreamProcess(«destructured»
): Process
<Promise
<Media
>>
Create a Audio Stream Processor and will own the stream passed-in
Parameters
Name | Type |
---|---|
«destructured» | AudioProcessOptions & ThrottleOptions |
Returns
createGetDisplayMedia
▸ createGetDisplayMedia(getDefaultConstraints
, getDisplayMedia?
): (constraints?
: DisplayMediaOptions
) => Promise
<undefined
| MediaStream
>
Parameters
Name | Type |
---|---|
getDefaultConstraints | () => DisplayMediaOptions |
getDisplayMedia | (options? : DisplayMediaStreamOptions ) => Promise <MediaStream > |
Returns
fn
▸ (constraints?
): Promise
<undefined
| MediaStream
>
Parameters
Name | Type |
---|---|
constraints? | DisplayMediaOptions |
Returns
Promise
<undefined
| MediaStream
>
createMedia
▸ createMedia(options
): MediaController
Create an object to interact with the media scream, which is usually used for our main stream.
See
MediaOptions
Parameters
Name | Type |
---|---|
options | MediaOptions |
Returns
createMediaSignal
▸ createMediaSignal<T
>(name
, crucial?
, variant?
): Signal
<T
>
Create a general signal with consistent scoped name
Default Value
true
See
Signal
Default Value
'generic'
Type parameters
Name | Type |
---|---|
T | undefined |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
name | string | undefined | Signal name |
crucial | boolean | true | Signify if the signal is unmissable. |
variant | SignalVariant | 'generic' | The variant of the signal |
Returns
Signal
<T
>
createMediaSignals
▸ createMediaSignals<K
>(more
, scope?
): Pick
<Required
<MediaSignals
>, SignalKeys
>
Create and return all required and optional (if specified with more
),
signals for media to work
See
- MediaSignalsOptional
- Signal
The following signals created by default
- 'onMediaChanged',
- 'onVAD',
- REQUIRED_SIGNAL_KEYS
Type parameters
Name | Type |
---|---|
K | extends "onDevicesChanged" | "onStatusChanged" | "onAudioMuteStateChanged" | "onVideoMuteStateChanged" | keyof StreamTrackSignals | "onStreamTrackMutedFinal" | "onStreamTrackUnmutedFinal" | "onStreamTrackEndedFinal" | "onStreamTrackEnabledFinal" |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
more | K [] | undefined | Keys from MediaSignalsOptional , |
scope | string | '' | any scope prefix for the generated signal name, |
Returns
Pick
<Required
<MediaSignals
>, SignalKeys
>
createPreviewStreamController
▸ createPreviewStreamController(«destructured»
): PreviewStreamController
Parameters
Name | Type |
---|---|
«destructured» | PreviewStreamParams |
Returns
createVideoStreamProcess
▸ createVideoStreamProcess(«destructured»
): Process
<Promise
<Media
>>
Parameters
Name | Type |
---|---|
«destructured» | VideoStreamProcessOptions |
Returns
deriveInitialPermissionStatus
▸ deriveInitialPermissionStatus(prevStatus
, getPermissionState?
): Promise
<UserMediaStatus
>
Parameters
Name | Type | Default value |
---|---|---|
prevStatus | UserMediaStatus | undefined |
getPermissionState | (anyActiveStream? : boolean ) => Promise <InputDevicePermission > | getInputDevicePermissionState |
Returns
Promise
<UserMediaStatus
>
getPermissionStatus
▸ getPermissionStatus(getPermissionState?
): Promise
<Initial
| InitialPermissionsGranted
| InitialPermissionsNotGranted
| InitialPermissionsVideoInputDenied
| InitialPermissionsAudioInputDenied
| InitialPermissionsVideoInputGranted
| InitialPermissionsAudioInputGranted
| InitialPermissionsGrantedVideoInputDenied
| InitialPermissionsGrantedAudioInputDenied
| PermissionsRejected
>
Parameters
Name | Type | Default value |
---|---|---|
getPermissionState | (anyActiveStream? : boolean ) => Promise <InputDevicePermission > | getInputDevicePermissionState |
Returns
Promise
<Initial
| InitialPermissionsGranted
| InitialPermissionsNotGranted
| InitialPermissionsVideoInputDenied
| InitialPermissionsAudioInputDenied
| InitialPermissionsVideoInputGranted
| InitialPermissionsAudioInputGranted
| InitialPermissionsGrantedVideoInputDenied
| InitialPermissionsGrantedAudioInputDenied
| PermissionsRejected
>
hasNoAudioDevices
▸ hasNoAudioDevices(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
hasNoDevice
▸ hasNoDevice(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
hasNoVideoDevices
▸ hasNoVideoDevices(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isAudioDeviceInUse
▸ isAudioDeviceInUse(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isDeviceInUse
▸ isDeviceInUse(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isDevicesInUse
▸ isDevicesInUse(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isFallback
▸ isFallback(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isFallbackAudio
▸ isFallbackAudio(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isFallbackVideo
▸ isFallbackVideo(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGranted
▸ isGranted(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedAudio
▸ isGrantedAudio(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedOnlyAudio
▸ isGrantedOnlyAudio(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedOnlyAudioNoVideoDevices
▸ isGrantedOnlyAudioNoVideoDevices(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedOnlyVideo
▸ isGrantedOnlyVideo(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedOnlyVideoNoAudioDevices
▸ isGrantedOnlyVideoNoAudioDevices(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isGrantedVideo
▸ isGrantedVideo(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isInitial
▸ isInitial(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isInitialPermissions
▸ isInitialPermissions(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isInitialPermissionsGranted
▸ isInitialPermissionsGranted(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isInitialPermissionsNotGranted
▸ isInitialPermissionsNotGranted(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isOnlyAudioError
▸ isOnlyAudioError(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isOnlyVideoError
▸ isOnlyVideoError(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isOverConstrained
▸ isOverConstrained(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isPromptAudio
▸ isPromptAudio(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isPromptVideo
▸ isPromptVideo(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isRejected
▸ isRejected(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isRejectedOnlyAudio
▸ isRejectedOnlyAudio(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isRejectedOnlyVideo
▸ isRejectedOnlyVideo(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isUnknownError
▸ isUnknownError(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
isVideoDeviceInUse
▸ isVideoDeviceInUse(status
): boolean
Parameters
Name | Type |
---|---|
status | UserMediaStatus |
Returns
boolean
setLogger
▸ setLogger(newLogger
): void
Parameters
Name | Type |
---|---|
newLogger | Logger |
Returns
void
toDeniedDevices
▸ toDeniedDevices(status?
): undefined
| DeniedDevices
Parameters
Name | Type |
---|---|
status? | UserMediaStatus |
Returns
undefined
| DeniedDevices